<template>
  <j-modal
    :confirmLoading="confirmLoading"
    :maskClosable="false"
    :title="title"
    :visible="visible"
    :width="1200"
    switchFullscreen
    @cancel="handleOk"
  >
    <template slot="footer">
      <a-button v-if="isCheck == true" key="submit" type="primary" @click="handleOk">
        返回
      </a-button>
      <a-button v-if="isCheck == false" key="submit" type="primary" @click="handleOks">
        提交
      </a-button>

    </template>
    <a-spin :spinning="confirmLoading">
      <a-form :form="form">
        <div style="display: flex;justify-content: space-between;">
          <span>入库日期：{{ model.storageTime }}</span>
          <span>入库单编号：</span>
        </div>
        <table class="table">
          <tr>
            <td>供货单位</td>
            <td>
              <a-form-item>
                <a-input
                  v-decorator="['supplier', { rules: [{ required: false, message: '请输入必填项' }] }]"
                  :disabled="ckdis"
                />
              </a-form-item>
            </td>
            <td>收货单位</td>
            <td>
              <a-form-item>
                <a-input
                  :disabled="ckdis"
                />
              </a-form-item>
            </td>
            <td rowspan="3">
              <a-upload
                :file-list="fileList1"
                :showUploadList="handleRemoveIcon[0]"
                list-type="picture-card"
                @change="handleChange"
                @preview="handlePreview"
              >
                <div v-if="fileList1.length <1 && isCheck == false">
                  <a-icon type="plus"/>
                  <div class="ant-upload-text">
                    Upload
                  </div>
                </div>
              </a-upload>
              <a-modal :footer="null" :visible="previewVisible" @cancel="handleCancel">
                <img :src="previewImage" alt="example" style="width: 100%"/>
              </a-modal>
            </td>
            <td rowspan="3">
              <a-upload
                :file-list="fileList2"
                :showUploadList="handleRemoveIcon[0]"
                list-type="picture-card"
                @change="handleChange2"
                @preview="handlePreview2"
              >
                <div v-if="fileList2.length <1 && isCheck == false">
                  <a-icon type="plus"/>
                  <div class="ant-upload-text">
                    Upload
                  </div>
                </div>
              </a-upload>
              <a-modal :footer="null" :visible="previewVisible2" @cancel="handleCancel2">
                <img :src="previewImage2" alt="example" style="width: 100%"/>
              </a-modal>
            </td>
          </tr>
          <tr>
            <td>车辆产品名称</td>
            <td>
              <a-form-item>
                <a-input
                  v-decorator="['brand', { rules: [{ required: false, message: '请输入必填项' }] }]"
                  :disabled="ckdis"
                />
              </a-form-item>
            </td>
            <td>车辆型号</td>
            <td>
              <a-form-item>
                <a-input
                  v-decorator="['carModel', { rules: [{ required: false, message: '请输入必填项' }] }]"
                  :disabled="ckdis"
                />
              </a-form-item>
            </td>
          </tr>
          <tr>
            <td>车辆品牌</td>
            <td>
              <a-form-item>
                <a-input
                  v-decorator="['brand', { rules: [{ required: false, message: '请输入必填项' }] }]"
                  :disabled="ckdis"
                />
              </a-form-item>
            </td>
            <td>排量</td>
            <td>
              <a-form-item>
                <a-input
                  v-decorator="['displacement', { rules: [{ required: false, message: '请输入必填项' }] }]"
                  :disabled="ckdis"
                />
              </a-form-item>
            </td>
          </tr>
          <tr>
            <td>车辆燃料种类</td>
            <td>
              <a-form-item>
                <a-input
                  v-decorator="['fuelType', { rules: [{ required: false, message: '请输入必填项' }] }]"
                  :disabled="ckdis"
                />
              </a-form-item>
            </td>
            <td>车辆颜色</td>
            <td>
              <a-form-item>
                <a-input
                  v-decorator="['outsideColor', { rules: [{ required: false, message: '请输入必填项' }] }]"
                  :disabled="ckdis"
                />
              </a-form-item>
            </td>
            <td rowspan="3">
              <a-upload
                :file-list="fileList3"
                :showUploadList="handleRemoveIcon[0]"
                action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
                list-type="picture-card"
                @change="handleChange3"
                @preview="handlePreview3"
              >
                <div v-if="fileList3.length <1 && isCheck == false">
                  <a-icon type="plus"/>
                  <div class="ant-upload-text">
                    Upload
                  </div>
                </div>
              </a-upload>
              <a-modal :footer="null" :visible="previewVisible3" @cancel="handleCancel3">
                <img :src="previewImage" alt="example" style="width: 100%"/>
              </a-modal>
            </td>
            <td rowspan="3">
              <a-upload
                :file-list="fileList4"
                :showUploadList="handleRemoveIcon[0]"
                action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
                list-type="picture-card"
                @change="handleChange4"
                @preview="handlePreview4"
              >
                <div v-if="fileList4.length <1 && isCheck == false">
                  <a-icon type="plus"/>
                  <div class="ant-upload-text">
                    Upload
                  </div>
                </div>
              </a-upload>
              <a-modal :footer="null" :visible="previewVisible4" @cancel="handleCancel4">
                <img :src="previewImage4" alt="example" style="width: 100%"/>
              </a-modal>
            </td>
          </tr>
          <tr>
            <td>识别代码(VIN)</td>
            <td>
              <a-form-item>
                <a-input
                  v-decorator="['vin', { rules: [{ required: false, message: '请输入必填项' }] }]"
                  :disabled="ckdis"
                />
              </a-form-item>
            </td>
            <td>车辆发动机号码</td>
            <td>
              <a-form-item>
                <a-input
                  v-decorator="['engineNo', { rules: [{ required: false, message: '请输入必填项' }] }]"
                  :disabled="ckdis"
                />
              </a-form-item>
            </td>
          </tr>
          <tr>
            <td>功率</td>
            <td>
              <a-form-item>
                <a-input
                  v-decorator="['motorPower', { rules: [{ required: false, message: '请输入必填项' }] }]"
                  :disabled="ckdis"
                />
              </a-form-item>
            </td>
            <td>发动机型号</td>
            <td>
              <a-form-item>
                <a-input
                  v-decorator="['engineModel', { rules: [{ required: false, message: '请输入必填项' }] }]"
                  :disabled="ckdis"
                />
              </a-form-item>
            </td>
          </tr>
          <tr>
            <td>额定载质量</td>
            <td>
              <a-form-item>
                <a-input
                  v-decorator="['loadQuality', { rules: [{ required: false, message: '请输入必填项' }] }]"
                  :disabled="ckdis"
                />
              </a-form-item>
            </td>
            <td>内饰颜色</td>
            <td>
              <a-form-item>
                <a-input
                  v-decorator="['interiorColor', { rules: [{ required: false, message: '请输入必填项' }] }]"
                  :disabled="ckdis"
                />
              </a-form-item>
            </td>
            <td>变速箱型号</td>
            <td>
              <a-form-item>
                <a-input
                  v-decorator="['gearbox', { rules: [{ required: false, message: '请输入必填项' }] }]"
                  :disabled="ckdis"
                />
              </a-form-item>
            </td>
          </tr>
          <tr>
            <td>车辆驱动形式</td>
            <td>
              <a-form-item>
                <a-input
                  v-decorator="['powerType', { rules: [{ required: false, message: '请输入必填项' }] }]"
                  :disabled="ckdis"
                />
              </a-form-item>
            </td>
            <td>生产企业名称</td>
            <td>
              <a-form-item>
                <a-input
                  v-decorator="['manufacturer', { rules: [{ required: false, message: '请输入必填项' }] }]"
                  :disabled="ckdis"
                />
              </a-form-item>
            </td>
            <td>车辆轮胎型号</td>
            <td>
              <a-form-item>
                <a-input
                  v-decorator="['tireNo', { rules: [{ required: false, message: '请输入必填项' }] }]"
                  :disabled="ckdis"
                />
              </a-form-item>
            </td>
          </tr>
          <tr>
            <td>动力蓄电池组编号</td>
            <td>
              <a-form-item>
                <a-input
                  v-decorator="['batteryNo', { rules: [{ required: false, message: '请输入必填项' }] }]"
                  :disabled="ckdis"
                />
              </a-form-item>
            </td>
            <td>发动机排放</td>
            <td>
              <a-form-item>
                <a-input
                  v-decorator="['displacement', { rules: [{ required: false, message: '请输入必填项' }] }]"
                  :disabled="ckdis"
                />
              </a-form-item>
            </td>
            <td>核定载客量</td>
            <td>
              <a-form-item>
                <a-input
                  v-decorator="['passengerCapacity', { rules: [{ required: false, message: '请输入必填项' }] }]"
                  :disabled="ckdis"
                />
              </a-form-item>
            </td>
          </tr>
          <tr>
            <td>随车手续</td>
            <td colspan="5">
              <a-checkbox-group :disabled="isCheck" @change="onChange">
                <a-row>
                  <a-col :span="6">
                    <a-checkbox value="A">整车合格证</a-checkbox>
                  </a-col>
                  <a-col :span="6">
                    <a-checkbox value="B">底盘合格证</a-checkbox>
                  </a-col>
                  <a-col :span="6">
                    <a-checkbox value="C">气瓶合格证</a-checkbox>
                  </a-col>
                  <a-col :span="6">
                    <a-checkbox value="D">随车工具一套</a-checkbox>
                  </a-col>
                  <a-col :span="6">
                    <a-checkbox value="E">反光衣</a-checkbox>
                  </a-col>
                  <a-col :span="6">
                    <a-checkbox value="F">保修卡</a-checkbox>
                  </a-col>
                  <a-col :span="6">
                    <a-checkbox value="G">说明书</a-checkbox>
                  </a-col>
                  <a-col :span="6">
                    <a-checkbox value="H">车辆一致性证书</a-checkbox>
                  </a-col>
                  <a-col :span="6">
                    <a-checkbox value="I">货物进口证明书</a-checkbox>
                  </a-col>
                  <a-col :span="6">
                    <a-checkbox value="J">进口机动车车辆随车检验单</a-checkbox>
                  </a-col>
                  <a-col :span="6">
                    <a-checkbox value="K">进口车辆电子信息</a-checkbox>
                  </a-col>
                </a-row>
              </a-checkbox-group>
            </td>
          </tr>
          <tr>
            <td>原车装备</td>
            <td colspan="5">
              <a-checkbox-group :disabled="isCheck" @change="onChange">
                <a-row>
                  <a-col :span="6">
                    <a-checkbox value="A">空调</a-checkbox>
                  </a-col>
                  <a-col :span="6">
                    <a-checkbox value="B">点烟器</a-checkbox>
                  </a-col>
                  <a-col :span="6">
                    <a-checkbox value="C">安全气囊</a-checkbox>
                  </a-col>
                  <a-col :span="6">
                    <a-checkbox value="D">电动天窗</a-checkbox>
                  </a-col>
                  <a-col :span="6">
                    <a-checkbox value="E">行车记录仪</a-checkbox>
                  </a-col>
                  <a-col :span="6">
                    <a-checkbox value="F">电动遥控门窗</a-checkbox>
                  </a-col>
                  <a-col :span="6">
                    <a-checkbox value="G">ABS防抱死系统</a-checkbox>
                  </a-col>
                  <a-col :span="6">
                    <a-checkbox value="H">冰箱</a-checkbox>
                  </a-col>
                  <a-col :span="6">
                    <a-checkbox value="I">烟灰缸</a-checkbox>
                  </a-col>
                  <a-col :span="6">
                    <a-checkbox value="J">车载电视</a-checkbox>
                  </a-col>
                  <a-col :span="6">
                    <a-checkbox value="K">电子手刹</a-checkbox>
                  </a-col>
                  <a-col :span="6">
                    <a-checkbox value="L">超速报警器</a-checkbox>
                  </a-col>
                  <a-col :span="6">
                    <a-checkbox value="M">自动巡航系统</a-checkbox>
                  </a-col>
                  <a-col :span="6">
                    <a-checkbox value="N">防盗报警装置</a-checkbox>
                  </a-col>
                  <a-col :span="6">
                    <a-checkbox value="O">备胎</a-checkbox>
                  </a-col>
                  <a-col :span="6">
                    <a-checkbox value="P">中控锁</a-checkbox>
                  </a-col>
                  <a-col :span="6">
                    <a-checkbox value="Q">电子座椅</a-checkbox>
                  </a-col>
                  <a-col :span="6">
                    <a-checkbox value="R">倒车雷达</a-checkbox>
                  </a-col>
                  <a-col :span="6">
                    <a-checkbox value="S">无钥匙启动</a-checkbox>
                  </a-col>
                  <a-col :span="6">
                    <a-checkbox value="T">GPS定位系统</a-checkbox>
                  </a-col>
                  <a-col :span="6">
                    <a-checkbox value="U">胎压监测装置</a-checkbox>
                  </a-col>
                  <a-col :span="6">
                    <a-checkbox value="V">音响</a-checkbox>
                  </a-col>
                  <a-col :span="6">
                    <a-checkbox value="W">多媒体</a-checkbox>
                  </a-col>
                  <a-col :span="6">
                    <a-checkbox value="X">儿童座椅</a-checkbox>
                  </a-col>
                  <a-col :span="6">
                    <a-checkbox value="Y">自动驻车</a-checkbox>
                  </a-col>
                  <a-col :span="6">
                    <a-checkbox value="Z">电动后备箱</a-checkbox>
                  </a-col>
                  <a-col :span="6">
                    <a-checkbox value="AA">气囊减震座椅</a-checkbox>
                  </a-col>
                  <a-col :span="6">
                    <a-checkbox value="AB">多功能方向盘</a-checkbox>
                  </a-col>
                </a-row>
              </a-checkbox-group>
            </td>
          </tr>
          <tr>
            <td>其他配置</td>
            <td colspan="5">
              <a-form-item>
                <a-input
                  :disabled="ckdis"
                />
              </a-form-item>
            </td>
          </tr>
          <tr>
            <td>运费(元)</td>
            <td width="100px">
              <a-form-item>
                <a-input v-model="model.freightCost"
                  :disabled="xgdis"
                />
              </a-form-item>
            </td>
            <td>汽车合格证编号</td>
            <td colspan="0.5">
              <a-form-item>
                <a-input
                  v-decorator="['certificateNo', { rules: [{ required: false, message: '请输入必填项' }] }]"
                  :disabled="ckdis"
                />
              </a-form-item>
            </td>
            <td>厂商指导价(元)</td>
            <td colspan="0.5">
              <a-form-item>
                <a-input v-model="model.directorPrice"
                  :disabled="xgdis"
                />
              </a-form-item>
            </td>
          </tr>
          <tr>
            <td>进价(元)</td>
            <td colspan="1">
              <a-form-item>
                <a-input v-model="model.carCost"
                  :disabled="xgdis"
                />
              </a-form-item>
            </td>
            <td>选装费(元)</td>
            <td colspan="1">
              <a-form-item>
                <a-input v-model="model.decorateCost"
                  :disabled="xgdis"
                />
              </a-form-item>
            </td>
            <td>价费合计(元)</td>
            <td colspan="1">
              <a-form-item>
                <a-input v-model="model.hjCost"
                  :disabled="xgdis"
                />
              </a-form-item>
            </td>
          </tr>
        </table>
        <div style="display: flex; justify-content: space-around;">
          <span>存放库房：{{ model.storeName }}</span>
          <span>保管员：{{ model.storekeeperName }}</span>
          <span>修改日期：{{ model.updateTime }}</span>
          <span>修改人：{{ model.updateUser }}</span>
        </div>
      </a-form>
    </a-spin>
  </j-modal>
</template>

<script>
function getBase64(file) {
  return new Promise((resolve, reject) => {
    const reader = new FileReader()
    reader.readAsDataURL(file)
    reader.onload = () => resolve(reader.result)
    reader.onerror = error => reject(error)
  })
}

import { getAction, httpAction } from '@/api/manage'
import { USER_INFO } from '@/store/mutation-types'
import Vue from 'vue'

export default {
  name: 'VehicleRegisterModel',
  data() {
    return {
      handleRemoveIcon: [
        { showRemoveIcon: true }
      ],
      isCheck: false,
      title: '交易信息',
      visible: false,
      accessoriesId: '',
      originalEquipmentId: '',
      xgdis: true,
      ckdis: true,
      model: {
        vin: '',
        supplier: '',
        ertificateNo: '',
        fuelType: '',
        engineNo: '',
        engineModel: '',
        displacement: '',
        gearbox: '',
        tireNo: '',
        outsideColor: '',
        carCost: '',
        decorateCost: '',
        directorPrice: '',
        freightCost: '',
        hjCost: '',
        storeId: '',
        storeName: '',
        storekeeperId: '',
        storekeeperName: '',
        updateTime: '',
        updateUser: '',
        storageTime: '',
        batteryNo: '',
        interiorColor: '',
        loadQuality: '',
        motorPower: '',
        powerType: '',
        passengerCapacity: ''
      },
      cxmSaleCarInfoDto: {},
      saleSource: [],
      SaleInfosLike: [],
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 }
      },
      previewVisible: false,
      previewImage: '',
      previewVisible2: false,
      previewImage2: '',
      previewVisible3: false,
      previewImage3: '',
      previewVisible4: false,
      previewImage4: '',
      fileList1: [
        {
          uid: '-1',
          name: '外观图片',
          status: 'done',
          url: ''
        }
      ],
      fileList2: [
        {
          uid: '-1',
          name: '二维码图片',
          status: 'done',
          url: ''
        }
      ],
      fileList3: [
        {
          uid: '-1',
          name: '铭牌图片',
          status: 'done',
          url: ''
        }
      ],
      fileList4: [
        {
          uid: '-1',
          name: '合格证图片',
          status: 'done',
          url: ''
        }
      ],
      confirmLoading: false,
      form: this.$form.createForm(this),
      validatorRules: {},
      url: {
        add: 'sale/cxmSaleCarInfo/addCarInfo',
        edit: 'sale/cxmSaleCarInfo/editCarInfo',
        saveDraft: 'cxm/cxmCommonBusiness/saveDraft',
        getDraft: 'cxm/cxmCommonBusiness/getDraft',
        getSaleInfosLike: 'cxm/cxmSalesInfo/getSaleInfosLike',
        getSaleInfos: '/cxm/cxmOrderManager/getSaleInfos'
      },
      showDing: false,
      showEnterpriseUscc: false
    }
  },
  created() {
  },
  computed: {
    importExcelUrl: function() {
      return `${process.env.VUE_APP_BASE_API}${this.url.edit}`
    }
  },
  methods: {
    handleCancel() {
      this.previewVisible = false
    },
    async handlePreview(file) {
      if (!file.url && !file.preview) {
        file.preview = await getBase64(file.originFileObj)
      }
      this.previewImage = file.url || file.preview
      this.previewVisible = true
    },
    handleChange({ fileList }) {
      this.fileList1 = fileList
    },

    handleCancel2() {
      this.previewVisible2 = false
    },
    async handlePreview2(file) {
      if (!file.url && !file.preview) {
        file.preview = await getBase64(file.originFileObj)
      }
      this.previewImage2 = file.url || file.preview
      this.previewVisible2 = true
    },
    handleChange2({ fileList }) {
      this.fileList2 = fileList
    },

    handleCancel3() {
      this.previewVisible3 = false
    },
    async handlePreview3(file) {
      if (!file.url && !file.preview) {
        file.preview = await getBase64(file.originFileObj)
      }
      this.previewImage3 = file.url || file.preview
      this.previewVisible3 = true
    },
    handleChange3({ fileList }) {
      this.fileList3 = fileList
    },

    handleCancel4() {
      this.previewVisible4 = false
    },
    async handlePreview4(file) {
      if (!file.url && !file.preview) {
        file.preview = await getBase64(file.originFileObj)
      }
      this.previewImage4 = file.url || file.preview
      this.previewVisible4 = true
    },
    handleChange4({ fileList }) {
      this.fileList4 = fileList
    },
    onChange() {

    },
    saleSelect(value) {
      console.log('saleSelect', value)
      for (let i = 0; i < this.SaleInfosLike.length; i++) {
        if (this.SaleInfosLike[i].salesName == value) {
          this.form.setFieldsValue({
            salesPhone: this.SaleInfosLike[i].salesPhone
          })
        }
      }
    },
    add(record) {
      console.log('add(record)', record)
      const that = this
      that.edit(record)
      // const that = this
      // let httpurl = this.url.getDraft
      // let params = {
      //   bType: 'order'
      // }
      // getAction(httpurl, params).then((res) => {
      //   if (res.success) {
      //     if (res.result) {
      //       that.edit(JSON.parse(res.result))
      //     } else {
      //       getAction(that.url.getSaleInfos, params).then((res) => {
      //         that.edit(res.result)
      //       })
      //     }
      //   } else {
      //     that.edit({})
      //   }
      // })
    },
    newfuelType(fuelType) {
      if (fuelType == 1) {
        return '油/电'
      } else if (fuelType == 2) {
        return '电'
      } else if (fuelType == 3) {
        return '油'
      }
    },
    newpowerType(powerType) {
      if (powerType == 1) {
        return '传统车'
      } else if (powerType == 2) {
        return '新能源'
      }
    },
    edit(record, value) {
      this.confirmLoading = true
      console.log(record, value)
      this.form.resetFields()
      this.model = Object.assign({}, record)
      console.log(this.model)
      if (!value) {
        console.log(1234)
        this.handleRemoveIcon[0].showRemoveIcon = false
      }
      let imgList = []

      if (this.model.appearanceImg) {
        imgList.push(this.model.appearanceImg)
      } else {
        if (value) {
          this.fileList1 = []
        } else {
          this.fileList1[0].name = '暂无 外观图片'
          imgList.push('')
        }
      }

      if (this.model.qrCodeImg) {
        imgList.push(this.model.qrCodeImg)
      } else {
        if (value) {
          this.fileList2 = []
        } else {
          this.fileList2[0].name = '暂无 二维码图片'
          imgList.push('')
        }
      }

      if (this.model.nameplateImg) {
        imgList.push(this.model.nameplateImg)
      } else {
        if (value) {
          this.fileList3 = []
        } else {
          this.fileList3[0].name = '暂无 铭牌图片'
          imgList.push('')
        }
      }

      if (this.model.certificateImg) {
        imgList.push(this.model.certificateImg)
      } else {
        if (value) {
          this.fileList4 = []
        } else {
          this.fileList4[0].name = '暂无 合格证图片'
          imgList.push('')
        }
      }

      console.log(imgList)
      if (imgList.toString() == ',,,') {
        imgList = ['']
      }
      getAction('/cxm/cxmCommonBusiness/downloadPlainMultiText?ids=' + imgList).then((res) => {
        console.log(res)
        if (res.success) {
          this.confirmLoading = false
          for (let i in res.result) {
            if (imgList.indexOf(res.result[i].id) !== -1) {
              console.log('存在该图片，id为' + res.result[i].id + '，当前id处于fileList' + (imgList.indexOf(res.result[i].id) + 1) + '位置')
              let postion = imgList.indexOf(res.result[i].id) + 1
              this['fileList' + postion][0].url = res.result[i].img
            }
          }
        } else {
          this.confirmLoading = false
        }
      })

      getAction('/sale/cxmSaleCarInfo/queryById?id=' + record.id).then((res) => {
        console.log(res)
        if (res.success) {
          this.form.setFieldsValue({
            supplier: res.result.supplier,
            manufacturer: res.result.manufacturer
          })
          this.model.storeName = res.result.storeName
          this.model.storekeeperName = res.result.storekeeperName
        }
      })

      this.visible = true
      this.$nextTick(() => {
        this.form.setFieldsValue({
          vin: this.model.vin,
          brand: this.model.brand,
          supplier: this.model.supplier,
          manufacturer: this.model.manufacturer,
          carModel: this.model.carModel,
          certificateNo: this.model.certificateNo,
          fuelType: this.newfuelType(this.model.fuelType),
          engineNo: this.model.engineNo,
          outsideColor: this.model.outsideColor,
          displacement: this.model.displacement,
          gearbox: this.model.gearbox,
          tireNo: this.model.tireNo,
          carCost: this.model.carCost,
          decorateCost: this.model.decorateCost,
          directorPrice: this.model.directorPrice,
          enterpriseUscc: this.model.enterpriseUscc,
          freightCost: this.model.freightCost,
          hjCost: this.model.hjCost,
          storeId: this.model.storeId,
          storeName: this.model.storeName,
          storekeeperId: this.model.storekeeperId,
          storekeeperName: this.model.storekeeperName,
          updateTime: this.model.updateTime,
          storageTime: this.model.storageTime,
          batteryNo: this.model.batteryNo,
          engineModel: this.model.engineModel,
          interiorColor: this.model.interiorColor,
          loadQuality: this.model.loadQuality,
          motorPower: this.model.motorPower,
          powerType: this.newpowerType(this.model.powerType),
          passengerCapacity: this.model.passengerCapacity,
          accessoriesId: this.accessoriesId,
          originalEquipmentId: this.originalEquipmentId
        })
      })
      if (value) {
        this.xgdis = false
        let myDate = new Date()
        let userinfo = Vue.ls.get(USER_INFO)
        this.model.updateTime = myDate.toLocaleDateString()
        this.model.updateUser = userinfo.username
      } else if (record.length !== 0 && !value) {
        this.isCheck = true
      }
      console.log(this.accessoriesId)
      console.log(this.originalEquipmentId)
    },
    close() {
      this.$emit('close')
      this.visible = false
      this.isCheck = false
      this.fileList1 = [
        {
          uid: '-1',
          name: '外观图片',
          status: 'done',
          url: ''
        }
      ],
        this.fileList2 = [
          {
            uid: '-1',
            name: '二维码图片',
            status: 'done',
            url: ''
          }
        ],
        this.fileList3 = [
          {
            uid: '-1',
            name: '铭牌图片',
            status: 'done',
            url: ''
          }
        ],
        this.fileList4 = [
          {
            uid: '-1',
            name: '合格证图片',
            status: 'done',
            url: ''
          }
        ],
        this.handleRemoveIcon = [
          { showRemoveIcon: true }
        ]
    },
    handleOks() {
      this.form.validateFields((err, values) => {
        if (!err) {
          this.confirmLoading = true
          this.cxmSaleCarInfoDto = this.model
          console.log(this.model)
          // this.cxmSaleCarInfoDto.carCost = this.model.carCost
          // this.cxmSaleCarInfoDto.decorateCost = this.model.decorateCost
          // this.cxmSaleCarInfoDto.directorPrice = this.model.directorPrice
          // this.cxmSaleCarInfoDto.freightCost = this.model.freightCost
          // this.cxmSaleCarInfoDto.hjCost  = this.model.hjCost
          let httpurl = this.importExcelUrl
          let method = 'post'
          let formData = Object.assign(this.cxmSaleCarInfoDto)
          //时间格式化
          // formData.orderDate = formData.orderDate ? formData.orderDate.format('YYYY-MM-DD HH:mm:ss') : null
          httpAction(httpurl, formData, method)
            .then((res) => {
              if (res.success) {
                console.log(res)
                this.$message.success(res.message)
                this.$emit('ok')
              } else {
                this.$message.warning(res.message)
              }
            })
            .finally(() => {
              this.confirmLoading = false
              this.close()
            })
        }
      })
    },
    handleOk() {
      this.close()
    },
    blur(e) {
      e.target.blur()
    }
  }
}
</script>

<style lang="less" scoped>
.table tr td {
  border: 1px solid #000;

  /deep/ .ant-upload {
    width: 100%;
    margin: 0;
    height: 120px;
    border: none;
  }

  .ant-form-item {
    margin-bottom: 0px;
  }
}

td {
  min-width: 180px;
}

/deep/ .ant-upload-list-item {
  width: 195px;
  height: 120px;
}
</style>